<?php
/**
 * 重庆柯一网络有限公司
 * 遵循MT协议，开源并可商业使用，没有任何限制
 * @Author:cqkyi
 * @Date: 2020/9/26 8:18
 * 官方惟一地址：www.cqkyi.com
 */

namespace app\apiadmin\controller;


use app\common\model\admin\FilesModel;
use app\common\model\admin\FilesSetModel;
use app\common\utils\Res;
use think\response\File;

class Files extends AuthController
{

    /**
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function set(){
        $param = $this->request->post();
        $types = $this->request->post('farea/a');
        $param['farea']= implode(',',$types);
        $result = FilesSetModel::addEdit($param);
        return Res::jsonResult($result);
    }

    public function index(){
        $param = $this->request->post();
        $limit =(int)$param['pageSize'];
        $offset = ($param['pageNumber'] - 1) * $limit;
        $map=[];
        if($param['type']!=3000){
            $map[] = ['type','=',$param['type']];
        }
        $res = FilesModel::pageMap($map, $offset, $limit);
        $total = FilesModel::pageMapCount($map);
        $data=[
            'list'=>$res,
            'total'=>$total
        ];
        return Res::ok("查询成功",$data);
    }

}